<?php
/**
*
* @package phpBB3
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
 
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include_once($phpbb_root_path . 'common.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include_once($phpbb_root_path . 'sv_common.' . $phpEx);
include_once($phpbb_root_path . 'sv_common_handler.' . $phpEx);
include_once($phpbb_root_path . 'ofc/php-ofc-library/open-flash-chart.' . $phpEx);

$in_fb_iframe = true;

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('stockvirtual');

$money = $user->data['user_money'];
$user_id 	= $user->data['user_id'];

if ($user_id == ANONYMOUS)
{
	login_box();
}

handle_personal_setting($user_id);



// display belief
$belief = "";

$result = get_personal_setting($user_id);
if (isset($result))
{
	$belief 						= $result['belief'];
	$news_max_number 				= $result['news_max_number'];
	$market_info_option				= $result['market_info'];
	$delegation_list_info_option	= $result['delegation_list_info'];
	$allow_ad_option				= $result['allow_ad'];
}
else
{
	// not record found, create a new one.
	$sql 	= 'INSERT INTO sv_personal_setting (user_id) VALUES (' . $user_id . ')';
	$result = $db->sql_query($sql); 
}


display_forums('', $config['load_moderators']);

// include nav links.
include_nav_links();

// Assign index specific vars
$template->assign_vars(array(

	'FORUM_IMG'				=> $user->img('forum_read', 'NO_NEW_POSTS'),
	'FORUM_NEW_IMG'			=> $user->img('forum_unread', 'NEW_POSTS'),
	'FORUM_LOCKED_IMG'		=> $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'),
	'FORUM_NEW_LOCKED_IMG'	=> $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'),

	'S_LOGIN_ACTION'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'),
	'S_DISPLAY_BIRTHDAY_LIST'	=> ($config['load_birthdays']) ? true : false,
	'U_MONEY'					=> number_format($money),
	
	'MARKET_INFO_OPTION'				=> $market_info_option,
	'DELEGATION_LIST_INFO_OPTION'		=> $delegation_list_info_option,
	'NEWS_MAX_NUMBER'					=> $news_max_number,
	'S_BELIEF'							=> $belief,
	'ALLOW_AD_OPTION'					=> $allow_ad_option,
	
	'S_SET_BELIEF_ACTION'						=> append_sid("{$phpbb_root_path}fb/personal_setting.$phpEx", 'mode=set_belief'),
	'S_SET_NEWS_MAX_NUMBER_ACTION'				=> append_sid("{$phpbb_root_path}fb/personal_setting.$phpEx", 'mode=set_news_max_number'),
	'S_SET_MARKET_INFO_ACTION'					=> append_sid("{$phpbb_root_path}fb/personal_setting.$phpEx", 'mode=set_market_info'),
	'S_SET_DELEGATION_LIST_INFO_ACTION'			=> append_sid("{$phpbb_root_path}fb/personal_setting.$phpEx", 'mode=set_delegation_list_info'),
	'S_SET_ALLOW_AD_ACTION'						=> append_sid("{$phpbb_root_path}fb/personal_setting.$phpEx", 'mode=set_allow_ad'),
	
	'U_MARK_FORUMS'		=> ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}index.$phpEx", 'hash=' . generate_link_hash('global') . '&amp;mark=forums') : '',
	'U_MCP'				=> ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '',
	
	'IN_FB_IFRAME'		=> $in_fb_iframe,
));

// Output page
page_header($user->lang['SV_PERSONAL_SETTING']);

$template->set_filenames(array(
	'body' => 'personal_setting.html')
);

page_footer();

?>